<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('业务员列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <p>昵称：</p>
                            <input type="text" name="nickName"/>
                        </li>
                        <li>
                            <p>真实姓名：</p>
                            <input type="text" name="realName"/>
                        </li>
                        <li>
                            <p>手机号：</p>
                            <input type="text" name="telephone"/>
                        </li>
                        <li>
                            <p>会员类型：</p>
                            <select name="vipType" th:with="type=${@dict.getType('vip_type')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <p>用户类型：</p>
                            <select name="userType" th:with="type=${@dict.getType('user_type')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <p>用户级别：</p>
                            <select name="userLevel" th:with="type=${@dict.getType('user_level')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:member:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:member:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:member:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:member:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:member:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:member:remove')}]];
    var vipTypeDatas = [[${@dict.getType('vip_type')}]];
    var userTypeDatas = [[${@dict.getType('user_type')}]];
    var userLevelDatas = [[${@dict.getType('user_level')}]];
    var addressFlag = [[${@permission.hasPermi('system:member:address')}]];
    var integralRecordFlag = [[${@permission.hasPermi('system:member:integralRecord')}]];
    var prefix = ctx + "system/member";
    var sexDatas = [[${@dict.getType('sys_user_sex')}]];

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            addressUrl: prefix + "/address/{id}",
            integralRecordUrl: prefix + "/integralRecord/{id}",
            sortName: "createTime",
            sortOrder: "desc",
            modalName: "业务员",
            columns: [{
                checkbox: true
            },
                {
                    field : 'id',
                    title : 'id',
                    visible: false
                },
                {
                    field : 'nickName',
                    title : '昵称',
                    align: 'left'
                },
                {
                    field : 'realName',
                    title : '真实姓名',
                    align: 'left'
                },
                {
                    field : 'telephone',
                    title : '手机号',
                    align: 'left'
                },
                {
                    field : 'sex',
                    title : '性别',
                    align: 'left',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(sexDatas, value);
                    }
                },
                {
                    field : 'email',
                    title : '邮箱',
                    align: 'left'
                },
                {
                    field : 'birthday',
                    title : '生日',
                    align: 'left',
                    width: '90',
                },
                {
                    field : 'address',
                    title : '联系地址',
                    align: 'left'
                },
                {
                    field : 'cover',
                    title : '头像',
                    align: 'left',
                    formatter: function(value, row, index) {
                        // 图片预览（注意：如存储在本地直接获取数据库路径，如有配置context-path需要使用ctx+路径）
                        // 如：/profile/upload/2019/08/08/3b7a839aced67397bac694d77611ce72.png
                        return $.table.imageView(value);
                    }
                },
                {
                    field : 'vipType',
                    title : '会员类型',
                    align: 'left',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(vipTypeDatas, value);
                    }
                },
                {
                    field : 'userType',
                    title : '用户类型',
                    align: 'left',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(userTypeDatas, value);
                    }
                },
                {
                    field : 'userLevel',
                    title : '用户级别',
                    align: 'left',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(userLevelDatas, value);
                    }
                },
                {
                    field : 'integralCount',
                    title : '积分值',
                    align: 'left'
                },
                {
                    field : 'remark',
                    title : '补充情况',
                    align: 'left'
                },
                {
                    field : 'card',
                    title : '名片',
                    align: 'left',
                    width: '150',
                    formatter: function(value, row, index) {
                        // 图片预览（注意：如存储在本地直接获取数据库路径，如有配置context-path需要使用ctx+路径）
                        // 如：/profile/upload/2019/08/08/3b7a839aced67397bac694d77611ce72.png
                        var imgs = '';
                        if(value!=null && value!=''){
                            var cards = value.split(";");
                            for(var c in cards){
                                imgs+='<img class=\'img-circle img-xs\' style="border-radius: 0;margin: 2px;" data-height=\'auto\' data-width=\'800px\' data-target=\'self\' src=\''+cards[c]+'\'/>';
                            }
                        }
                        return imgs
                    }
                },
                {
                    field : 'createTime',
                    title : '创建时间',
                    sortable: true
                },
                {
                    title: '操作',
                    align: 'center',
                    align: 'left',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        actions.push('<a class="btn btn-primary btn-xs ' + addressFlag + '" href="javascript:void(0)" onclick="$.operate.address(\'' + row.id + '\')"><i class="fa fa-address-card"></i>地址</a> ');
                        actions.push('<a class="btn btn-primary btn-xs ' + integralRecordFlag + '" href="javascript:void(0)" onclick="$.operate.integralRecord(\'' + row.id + '\')"><i class="fa fa-plus"></i>积分记录</a> ');
                        actions.push('<a class="btn btn-info  btn-xs" href="javascript:void(0)" onclick="openLayer(\'' + row.id + '\')"><i class="fa fa-users"></i>下级用户</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function openLayer(id){
        var options = {
            title: '下级用户',
            url: prefix + "/getEcharts/" + id,
            btn : false,
        };
        $.modal.openOptions(options);
    }
</script>
</body>
</html>